/*
 * @userName: 湫之恋
 * @Author: Seven
 * @Date: 2020-07-02 17:57:07
 * @LastEditors: Seven
 * @LastEditTime: 2020-07-02 18:34:54
 */
const mongoose = require("mongoose");
const adminModel = mongoose.model("adminModel");

module.exports.getAllAdmin = async function(getParams){
    return await adminModel.find().
    limit(parseInt(getParams.perItemNum)).
    skip((getParams.currentPage-1)*getParams.perItemNum);
}

module.exports.getOneAdmin = async function(getParams){
    return await adminModel.find(getParams);
}

module.exports.getAllAdminCount = async function(){
    return await adminModel.countDocuments();
}

// 登录
module.exports.login3 = async (data) => {
    return await mongoose.model('adminModel').find(data)
}
module.exports.updateAdmin = async function(postParams){
    return await adminModel.updateOne({_id:postParams._id},{
        username:postParams.username,
        password:postParams.password,
        identity:postParams.identity,
    });
}

module.exports.delAdmin = async function(postParams){
    return await adminModel.deleteOne(postParams);
}

module.exports.addAdmin = async function(postParams){
    return await adminModel.create(postParams);
}